/*
 * @Author: FanWeiHua
 * @Date: 2021-07-27 09:41:08
 * @LastEditTime: 2021-08-02 10:05:28
 * @Description:
 */
import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router';

// 首页
const Index = () => import('../view/index.vue');
// 没有映射路由
const NotFound = () => import('../view/notFound/notFound.vue');
// 操作
const Handle = () => import('../view/handle/index.vue');
// 默认操作页
const UnDemo = () => import('../view/unDemo/unDemo.vue');
// demo
const Demo = () => import('../view/demo/demo.vue');
// demo1
const Demo1 = () => import('../view/demo1/demo1.vue');
// demo2
const Demo2 = () => import('../view/demo2/demo2.vue');
// demo3
const Demo3 = () => import('../view/demo3/demo3.vue');
const router = createRouter({
  history:
    webpackConfig.nodeEnv === 'local'
      ? createWebHashHistory(webpackConfig.publicPath)
      : createWebHistory(webpackConfig.publicPath),
  routes: [
    { path: '/:pathMatch(.*)*', name: 'NotFound', component: NotFound },
    {
      name: '初始化',
      path: '/',
      component: Index
    },
    {
      name: '操作',
      path: '/handle',
      component: Handle,
      children: [
        {
          name: '默认',
          path: '',
          component: UnDemo
        },
        {
          name: 'demo',
          path: 'demo',
          component: Demo
        },
        {
          name: 'demo1',
          path: 'demo1',
          component: Demo1
        },
        {
          name: 'demo2',
          path: 'demo2',
          component: Demo2
        },
        {
          name: 'demo3',
          path: 'demo3',
          component: Demo3
        }
      ]
    }
  ]
});
// 路由元信息,全局的导航钩子
router.beforeEach((to, from, next) => {
  next();
});
export default router;
